import { defineStore } from "pinia";
import { queryTree } from '@/module/org/api/company'
import Validator from '@/utils/Validator';
const useCompayStore = defineStore('company', () => {
    const companyTree = ref([])
    function getTree() {
        return new Promise(function (resolve, reject) {
            if (Validator.isEmpty(companyTree.value)) {
                queryTree().then(res => {
                    console.log('run query dept')
                    companyTree.value = res
                    //console.log(res)
                    resolve(companyTree.value)
                })
            } else {
                resolve(companyTree.value)
            }
        })
    }
    return { companyTree, getTree }
})
export default useCompayStore;